package com.luck.pf.common.logic;

import java.util.List;

import org.apache.log4j.Logger;

import com.luck.pf.common.Constants;
import com.luck.pf.common.entity.CodeNameVO;

public class InitBeanImpl extends InitBean {
	public final static Logger log = Logger.getLogger(InitBeanImpl.class);
	/**
	 * 导入本系统中的参数
	 */
	public void loadSystemParam(){
		List<String> paramList = baseDao.find("select distinct paramCode from SysParams t ");
		for(String next:paramList){
			log.info("读取参数:["+next+"]");
			Constants.params.put(next, this.findParamItemList(next));
		}
	}
	
	/**
	 * 查找参数项列表
	 * @param itemVariable
	 * @return
	 */
	protected List<CodeNameVO> findParamItemList(String vCode){
		return (List<CodeNameVO>)baseDao.find("select new com.luck.pf.common.entity.CodeNameVO(t.paramValue as code, t.paramName as name) " +
				"from SysParams t where t.paramCode = ? and t.parentParam is not null order by t.paramValue asc ",vCode);		
	}
}
